package org.yoyo.classroom.service.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yoyo.classroom.domain.po.Permission;
import org.yoyo.classroom.mapper.PermissionMapper;
import org.yoyo.classroom.service.PermissionService;

import java.util.List;

@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public List<Permission> getAllPermissions() {
        return permissionMapper.selectAll();
    }

    @Override
    public Permission getPermissionById(Long id) {
        return permissionMapper.selectById(id);
    }

    @Override
    public boolean addPermission(Permission permission) {
        return permissionMapper.insert(permission) > 0;
    }

    @Override
    public boolean updatePermission(Permission permission) {
        return permissionMapper.updateById(permission) > 0;
    }

    @Override
    public boolean deletePermission(Long id) {
        return permissionMapper.deleteById(id) > 0;
    }

    @Override
    public List<Permission> findPermissionByRoleId(Integer roleId) {
        return permissionMapper.findPermissionByRoleId(roleId);
    }
}
